package com.xiaoma.verbal.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.verbal.baseDao.BaseDaoImpl;
import com.xiaoma.verbal.domain.PayAudioGrab;

@Repository
public class PayAudioGrabDao extends BaseDaoImpl<PayAudioGrab>{

    public void comfirmGrab(int audioId) {
        jdbcTemplate.update("update pay_audio_grab set status = 1 where audio_id = ?", audioId);
    }
    
    @SuppressWarnings("unchecked")
    public List<PayAudioGrab> findByUserId(int userId) {
        String sql = "select a.* from pay_audio_grab a left pay_audio b on a.audio_id = b.id where b.user_id = ? and a.status = 0 order by b.id desc";
        List<?> list = jdbcTemplate.query(sql, new DefaultRowMapper(PayAudioGrab.class, getNameHandler()), userId);
        return (List<PayAudioGrab>)list;
    }
}
